@extends('admin.layout.base')
@section('title', '权限列表页')
@section('content')
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            分组列表
            <!--<small>preview of simple tables</small>-->
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Tables</a></li>
            <li class="active">Simple</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title"></h3>
                        <a href="{{ url("/admin/group/create") }}" class="btn btn-success">添加分组</a>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered">
                            <tr>
                                <th style="width: 10px">#</th>
                                <th>名称</th>
                                <th>权限</th>
                                <th>操作</th>
                                <!--<th style="width: 40px">Label</th>-->
                            </tr>
                            @foreach($groups as $group)
                            <tr>
                                <td>{{$group->id}}</td>
                                <td>{{$group->title}}</td>
                                <td>
                                        @foreach($rules as $key=>$rule)
                                        @if($key % 4 ==0)<p>@endif
                                        @if(in_array($rule->id, explode(",", $group->rules)))
                                        <input type="checkbox" name="rule" value="{{$rule->id}}" groupid="{{ $group->id }}" checked  class="subcheck" />{{$rule->title}}、
                                        @else
                                        <input type="checkbox" name="rule" value="{{$rule->id}}" groupid="{{ $group->id }}" class="subcheck" />{{$rule->title}}、
                                        @endif
                                        @if($key % 4 == 3)</p>@endif
                                        @endforeach
                                </td>
                                <td><a href="{{url("/admin/group/{$group->id}/edit")}}" class="btn btn-info" />编辑</a> <a href="{{url("/admin/group/delete/{$group->id}")}}" class="btn btn-info" />删除</a></td>
                            </tr>
                            @endforeach
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">
                        <ul class="pagination pagination-sm no-margin pull-right">
                            <li><a href="#">&laquo;</a></li>
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">&raquo;</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
@endsection
@section('pluginscript')
<!-- Slimscroll -->
<script src="{{ asset('/dist/admin/plugins/slimScroll/jquery.slimscroll.min.js') }}"></script>
<!-- FastClick -->
<script src="{{ asset('/dist/admin/plugins/fastclick/fastclick.js') }}"></script>
<script type="text/javascript">
$(function(){
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': "{{ csrf_token() }}"
        }
    });
});
</script>
<script src="/dist/admin/js/group_index.js"></script>
@endsection
